home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / superv22.zip / EXEC.DOC < prev    next >
Text File  |  1986-12-02  |  4KB  |  98 lines

  1.             Execute other programs from Turbo Pascal
  2.                        Written/Compiled by 
  3.                           Doctor Debug
  4.  
  5.  
  6.      This will give a brief description of the functions included 
  7. with EXEC.INC. It allows the Turbo programmer to call other 
  8. applications from within a pascal program which has been compiled 
  9. to a COM file. None of these will work in the Turbo environment.
  10.  
  11.      One word of warning - you must leave some memory for the 
  12. other applications. You can do this by specifying the Maximum 
  13. Free Dynamic Memory to be less than all the rest of the machine's 
  14. memory, which is what Turbo defaults to. I have found that 
  15. setting this to $1000 (4096 bytes) is usually sufficient unless 
  16. your program does a great deal of heap operations or recursion. 
  17. I suggest that you do what I do, that is, play with the numbers 
  18. until you achieve a happy medium. If you reserve too little 
  19. memory for other applications, the result of an Exec, Shell, or 
  20. ExecCommand will be an 8, which indicates not enough memory. If 
  21. you allocate too little memory for your Turbo program's heap, you 
  22. will get a 'Stack-Heap collision' error from Turbo.
  23.  
  24.      In general, everything you pass to these functions should be 
  25. a string of type String[255], and the functions will return an 
  26. integer error code. A zero return code means that the function 
  27. was completed successfully. Any other value is the DOS error 
  28. code:
  29.  
  30.    Code    Meaning
  31.     2       File not Found
  32.     3       Path not Found
  33.     4       Too Many Open Files
  34.     5       Access Denied
  35.     7       Control Blocks Destroyed (Reboot!!!)
  36.     8       Insufficient Memory
  37.     
  38.      If any other code returns, consult the DOS Technical 
  39. Reference manual's list of Function error codes.
  40.  
  41. Function Exec(Command: Exec_Str255): Integer;
  42.  
  43.    This function executes the passed command, but the full 
  44. filename (including the extension) must be included and the 
  45. program must exist on the current directory. PATH or SEARCH will 
  46. not help you here.
  47.  
  48. Function ExecCommand(Command: Exec_Str255): Integer;
  49.  
  50.      This function loads a new copy of COMMAND.COM and then 
  51. passes your Command String to it. This is the preferred way of 
  52. executing an application, because you can format the command 
  53. string just as you would type it into the system and also PATH 
  54. and SEARCH will work just fine, meaning that the file doesn't 
  55. necessarily have to be in the same directory as your program. The 
  56. only drawback is that another copy of Command.Com takes up a 
  57. little memory. Another consideration is that programs Executed in 
  58. this way load just a little slower.
  59.  
  60.      COMMAND.COM does not have to exist on the same directory as 
  61. the program, for ExecCommand looks at the COMSPEC environment 
  62. parameter and finds COMMAND.COM wherever the system booted from. 
  63. Remember this if you run your program from a floppy based system 
  64. - COMMAND.COM has to exist SOMEWHERE!
  65.  
  66. Function Shell: Integer;
  67.  
  68.      This is a special case of ExecCommand which will give the 
  69. user a DOS prompt and let him dally to his heart's content. Your 
  70. Turbo program will not regain control until the user types EXIT 
  71. from the DOS prompt. 
  72.  
  73.      The following two functions are used internally to find the 
  74. COMSPEC parameter, but you may want to use them in your programs 
  75. also:
  76.  
  77. Function GetEnvString(Command: Exec_Str255): Exec_Str255;
  78.  
  79.      Pass this function an Environment label (i.e. COMSPEC, PATH, 
  80. etc) and if that label is defined in the current environment the 
  81. setting for that label will be returned. An empty string will be 
  82. returned if that item does not exist. Make sure you pass the 
  83. Environment Parameter as CAPITALS.
  84.  
  85. Function ComSpec: Exec_Str255;
  86.  
  87.      Using the above function, this function returns the current 
  88. drive, path and name of the COMMAND.COM used by DOS. This is very 
  89. handy information.
  90.  
  91.      All of these functions have been extensively tested and 
  92. should work fine. If you have any problems, questions, or 
  93. suggestions you can reach me at the NeverBoard Fido BBS, (412) 
  94. 733-4842. 
  95.  
  96. Good Day from Doctor Debug.
  97.  
  98.